<template>
        <el-card shadow="never" style="max-height: 700px; overflow: auto">
            <el-form ref="form" :model="form" :rules="rules" label-width="90px" :disabled="disabled">
                <el-form-item label="id:" prop="id" v-show="false">
                    <el-input v-model="form.id" disabled />
                </el-form-item>
                <el-form-item label="订单号:" prop="order_number">
                    <el-input v-model="form.order_number" placeholder="请输入订单号" clearable />
                </el-form-item>
                <el-form-item label="订单商品信息:" prop="order_product_id">
                    <el-input v-model="form.order_product_id" placeholder="请输入订单商品信息" clearable />
                </el-form-item>
                <el-form-item label="订单金额:" prop="order_money">
                    <el-input v-model="form.order_money" placeholder="请输入订单金额" clearable />
                </el-form-item>
                <el-form-item label="订单时间:" prop="order_time">
                    <el-date-picker v-model="form.order_time" type="datetime" value-format="yyyy-MM-dd HH:mm:ss" placeholder="选择订单时间" />
                </el-form-item>        

                <el-form-item label="发货状态:" prop="delivery_status">
                    <el-input-number v-model="form.delivery_status" :step="1" :min="0"></el-input-number>
                </el-form-item>
                <el-form-item label="spu编号:" prop="brand">
                    <el-input v-model="form.brand" placeholder="请输入spu编号" clearable />
                </el-form-item>
                <el-form-item label="订单sku:" prop="sku">
                    <el-input v-model="form.sku" placeholder="请输入订单sku" clearable />
                </el-form-item>
                <el-form-item label="颜色:" prop="color">
                    <el-input v-model="form.color" placeholder="请输入颜色" clearable />
                </el-form-item>
                <el-form-item label="尺码:" prop="size">
                    <el-input v-model="form.size" placeholder="请输入尺码" clearable />
                </el-form-item>
                <el-form-item label="数量:" prop="num">
                    <el-input-number v-model="form.num" :step="1" :min="0"></el-input-number>
                </el-form-item>
                <el-form-item label="店铺:" prop="site">
                    <el-input-number v-model="form.site" :step="1" :min="0"></el-input-number>
                </el-form-item>

                <el-form-item>
                    <el-button type="primary" @click="submitForm">确认 </el-button>
                    <el-button type="warning" @click="cancel">取消 </el-button>
                </el-form-item>
            </el-form>
        </el-card>
</template>

<script>
export default {
    name: 'EditForm',
    props: {
        findFormData: {
            type: Object,
            default: {}
        },
        editFormParams: {
            type: Object,
            default: {}
        },
        // 表单是否禁用
        disabled: {
            type: Boolean,
            default: false,
        },
        
    },
    data() {
        return {
            // 编辑表单验证规则
            rules: {
                order_number: [{ required: true, message: "请输入订单号", trigger: "blur" }],
                order_product_id: [{ required: true, message: "请输入订单商品信息", trigger: "blur" }],
                order_money: [{ required: true, message: "请输入订单金额", trigger: "blur" }],
                delivery_status: [{ required: true, message: "请输入发货状态", trigger: "blur" }],
                brand: [{ required: true, message: "请输入spu编号", trigger: "blur" }],
                sku: [{ required: true, message: "请输入订单sku", trigger: "blur" }],
                color: [{ required: true, message: "请输入颜色", trigger: "blur" }],
                size: [{ required: true, message: "请输入尺码", trigger: "blur" }],
                num: [{ required: true, message: "请输入数量", trigger: "blur" }],
                site: [{ required: true, message: "请输入店铺", trigger: "blur" }],
        
            },
            form: {  },
          

        }
    },
    watch: {
        findFormData: {
           handler(nval) {
                if (JSON.stringify(nval) != '{}') {
                    this.$nextTick(() => {
                        this.form = nval
                    })
                }
            },
            immediate: true,
            deep: false,
        },
        
    },
    methods: {
        // 取消按钮
        cancel() {
            this.$emit('editFormCancel')
        },

        submitForm() {
            this.$refs['form'].validate((valid, obj) => {
                if (valid) {
                    this.$emit('submitForm', this.form)
                }
            })
        },

        // 表单重置
        reset() {
            this.resetForm('form')
        }
    }
}
</script>
